<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/vue-2.4.0.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <button @click="bgcolor">点击开关灯</button>
    </div>
  </body>
  <script>
    var x = true;
    let vm = new Vue({
      el: "#app",
      data: {},
      methods: {
        bgcolor() {
          if (x) {
            document.body.style.backgroundColor = "black";
            x = false;
          } else {
            document.body.style.backgroundColor = "white";
            x = true;
          }
        },
      },
    });
  </script>
</html>
